<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="stylesheet/style.css">
<title></title>
</head>
<body>
	<div style="width:900px;margin:auto;border:0px solid black;">
		
		<jsp:include page="../common/header.jsp"/>
		<div style="height:5px;">
			<!-- Spacer -->
		</div>
		<div id="content">
			<s:form action="add_view_movie.action" method="post">
			 <s:if test="%{#session.loginUser.username == 'admin'}">
			 	<s:submit value="Add New" align="right"/>
			 </s:if>
			 <table style="width:100%;margin-top:10px;" cellpadding="0" cellspacing="0">
				<s:iterator var="movieDataTable" value="movieDataTables">
					<tr>
						<td colspan="3" id="table-header"><s:property value="#movieDataTable.genre.name"/></td>
						
					</tr>
					<tr>
						<td style="width:200px;" id="table-subheader">
							Title
						</td>
						<td style="width:500px;" id="table-subheader">
							Summary
						</td>
						
						<s:if test="%{#session.loginUser.username == 'admin'}">
						<td id="table-subheader">
						   Actions
						</td>
						</s:if>
					</tr>
					<tr>
						<td colspan="3" style="height:20px;"></td>
					</tr>
					<s:iterator var="movie" value="#movieDataTable.movies">
					   <!-- start movie detail  url -->
						<s:url action="detail_movie" var="detail_movie">
							<s:param name="movie_id" value="#movie.id"></s:param>
						</s:url>
						<!-- end movie detail url -->
						<s:url action="edit_movie_view" var="edit_movie_view">
							<s:param name="movie_id" value="#movie.id"></s:param>
						</s:url>
						
						<s:url action="delete_movie_by_id" var="delete_movie_by_id">
							<s:param name="movie_id" value="#movie.id"></s:param>
						</s:url>
						
						<tr>
							<td id="table-subheader-title">
								<s:a href="%{detail_movie}">
									<s:property value="#movie.title"/>
							</s:a>
						</td>
						<td style="width:300px;text-align:justify;">
							<s:property value="#movie.summary"/>
						</td>
						<s:if test="%{#session.loginUser.username == 'admin'}">
						<td id="table-subheader">
						
							<s:a href="%{edit_movie_view}">
								Edit
							</s:a>
							
							<s:a href="%{delete_movie_by_id}">
								Delete
							</s:a>
						</td>
						</s:if>					
					</tr>
					<tr>
						<td colspan="3" style="height:10px;"></td>
					</tr>
				</s:iterator>
				<tr>
					<td colspan="3" style="border-bottom:0px solid black;"></td>
				</tr>
			</s:iterator>
			
		</table>
		
		<s:if test="%{#session.loginUser.username == 'admin'}">
		  	<div style="height:20px"><!-- spacer --></div>
			<s:submit value="Add New" align="left"/>
		</s:if>
		</s:form>
		</div>
		
		<div style="height:5px;">
			<!-- Spacer -->
		</div>
		<jsp:include page="../common/footer.jsp"/>
	</div>
</body>
</html>

